
package hk.ces.oxfam.patch.db.result;

import hk.ces.oxfam.patch.obj.Bean;
import hk.ces.oxfam.patch.obj.BeanPacker;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author ReutyCheng
 */
public abstract class BeanResult<B extends Bean> extends AbstractAdvanceResult
{
  public BeanResult(SQLResult baseResult)
  {
    super(baseResult);
  }

  public List<B> getPackedResult()
  {
    List<B> resultList = new ArrayList<B>();
    BeanPacker<B> packer = this.packer(this);
    for (Object[] innerResult : this.getRows())
    {
      resultList.add(packer.pack(innerResult));
    }
    
    return resultList;
  }

  public abstract BeanPacker<B> packer(SQLResult result);
}
